package com.tenglong.teacher.ui.adapter.viewholder;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.tenglong.teacher.R;
import com.tenglong.teacher.services.HelpAndFeedbackInfo;
import com.tenglong.teacher.ui.WebActivity;
import com.tenglong.teacher.ui.adapter.viewholder.base.BaseViewHolder;

/**
 * @author hdx on 2019/4/24.
 */
public class HelpAndFeedBackViewHolder extends BaseViewHolder<HelpAndFeedbackInfo> {
    private HelpAndFeedbackInfo data;
    private TextView tv;

    public HelpAndFeedBackViewHolder(View itemView) {
        super(itemView);
        initView();
        setListeners();
    }

    private void initView() {
        tv = itemView.findViewById(R.id.tv);
    }

    private void setListeners() {
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(itemView.getContext(), WebActivity.class);
                intent.putExtra(WebActivity.KEY_WEB_URL, data.childUrl);
                itemView.getContext().startActivity(intent);
            }
        });
    }

    @Override
    public void setLayoutInfo(HelpAndFeedbackInfo info) {
        this.data = info;
        tv.setText((getLayoutPosition() + 1) + "、" + info.childName);
    }
}
